<!DOCTYPE html>












  


<html class="theme-next mist use-motion" lang="zh-CN">
<head><meta name="generator" content="Hexo 3.8.0">
  <meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=2">
<meta name="theme-color" content="#222">


  <script>
  (function(i,s,o,g,r,a,m){i["DaoVoiceObject"]=r;i[r]=i[r]||function(){(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;a.charset="utf-8";m.parentNode.insertBefore(a,m)})(window,document,"script",('https:' == document.location.protocol ? 'https:' : 'http:') + "//widget.daovoice.io/widget/0f81ff2f.js","daovoice")
  daovoice('init', {
      app_id: "15fc8e87"
    });
  daovoice('update');
  </script>






  
  
    
    
  <script src="/lib/pace/pace.min.js?v=1.0.2"></script>
  <link href="/lib/pace/pace-theme-minimal.min.css?v=1.0.2" rel="stylesheet">







<meta http-equiv="Cache-Control" content="no-transform">
<meta http-equiv="Cache-Control" content="no-siteapp">






















<link href="/lib/font-awesome/css/font-awesome.min.css?v=4.6.2" rel="stylesheet" type="text/css">

<link href="/css/main.css?v=6.3.0" rel="stylesheet" type="text/css">


  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png?v=6.3.0">


  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32-next.png?v=6.3.0">


  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16-next.png?v=6.3.0">


  <link rel="mask-icon" href="/images/logo.svg?v=6.3.0" color="#222">









<script type="text/javascript" id="hexo.configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    root: '/',
    scheme: 'Mist',
    version: '6.3.0',
    sidebar: {"position":"left","display":"post","offset":12,"b2t":true,"scrollpercent":true,"onmobile":false},
    fancybox: false,
    fastclick: false,
    lazyload: false,
    tabs: true,
    motion: {"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}},
    algolia: {
      applicationID: '',
      apiKey: '',
      indexName: '',
      hits: {"per_page":10},
      labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
    }
  };
</script>


  




  <meta name="description" content="刚开始接触Docker之后，就对容器和镜像的概念有所迷惑，上一篇也简单的说了一下之前的见解，其实并不准确，在之后的学习中再加上网上找的资料，发现了下面的这一片博文，一定要多看几遍，看完思考再看，就会对容器和镜像有更深刻的认识。">
<meta name="keywords" content="Docker">
<meta property="og:type" content="article">
<meta property="og:title" content="学习Docker之10张图带你深入理解Docker容器和镜像">
<meta property="og:url" content="http://blog.wangxc.club/2018/01/27/学习Docker之10张图带你深入理解Docker容器和镜像/index.html">
<meta property="og:site_name" content="冬与晨">
<meta property="og:description" content="刚开始接触Docker之后，就对容器和镜像的概念有所迷惑，上一篇也简单的说了一下之前的见解，其实并不准确，在之后的学习中再加上网上找的资料，发现了下面的这一片博文，一定要多看几遍，看完思考再看，就会对容器和镜像有更深刻的认识。">
<meta property="og:locale" content="zh-CN">
<meta property="og:image" content="http://dockerone.com/uploads/article/20151103/d6ad9c257d160164480b25b278f4a2ad.png">
<meta property="og:image" content="http://dockerone.com/uploads/article/20151103/522c40256149bad2b471d1a97c2b6bb5.png">
<meta property="og:image" content="http://dockerone.com/uploads/article/20151103/b7fb9d924aa12099369c4793050fcfab.png">
<meta property="og:image" content="http://dockerone.com/uploads/article/20151103/8022edeebeb313742bd615aa695bbad3.png">
<meta property="og:image" content="http://dockerone.com/uploads/article/20151103/1dc88de5a114b68d05c37aab7e103597.png">
<meta property="og:image" content="http://dockerone.com/uploads/article/20151103/e42d56394306894244af5bc6d757bee1.png">
<meta property="og:image" content="http://dockerone.com/uploads/article/20151103/5cca590212e2a110be84cbdd3b6101ee.png">
<meta property="og:image" content="http://dockerone.com/uploads/article/20151103/1ead4d955aeb5d968219794489948fc2.png">
<meta property="og:image" content="http://dockerone.com/uploads/article/20151031/1397bbddca6651a3ae0316daa8d6d1cd.jpg">
<meta property="og:image" content="http://dockerone.com/uploads/article/20151103/bbe622329b399778b077617ae6468676.png">
<meta property="og:image" content="http://dockerone.com/uploads/article/20151031/3f08537e309b923d049fdde3d3a1f926.jpg">
<meta property="og:image" content="http://dockerone.com/uploads/article/20151031/4178f2b64f6a2eeb994866931417f263.jpg">
<meta property="og:image" content="http://dockerone.com/uploads/article/20151103/ea18907dedcd8893b39ae1f9e3ad8a3e.png">
<meta property="og:image" content="http://dockerone.com/uploads/article/20151031/fafeb4eb072e64b54b9979930a6d8db7.jpg">
<meta property="og:image" content="http://dockerone.com/uploads/article/20151031/120d394e57a03a5bb996b23e6e373cf1.jpg">
<meta property="og:image" content="http://dockerone.com/uploads/article/20151031/f8b34de7f7f325e2933aac5cc679e224.jpg">
<meta property="og:image" content="http://dockerone.com/uploads/article/20151031/6b3d2d1cae5a26961dc554fc05783b22.jpg">
<meta property="og:image" content="http://dockerone.com/uploads/article/20151031/081cf8fbe8ab4dea4130ce2f25eae071.jpg">
<meta property="og:image" content="http://dockerone.com/uploads/article/20151031/8aeee0c4c1134ee9d0c2200e03defcf4.jpg">
<meta property="og:image" content="http://dockerone.com/uploads/article/20151031/2b34576a2187a972d4cc1cf9346658e2.jpg">
<meta property="og:image" content="http://dockerone.com/uploads/article/20151031/bba4521356b43813a634a0859fa53743.jpg">
<meta property="og:image" content="http://dockerone.com/uploads/article/20151031/df0fadb17158696cdce49a8e30f8c4c4.jpg">
<meta property="og:image" content="http://dockerone.com/uploads/article/20151031/f642149d0144c83679dd228c93a91a37.jpg">
<meta property="og:image" content="http://dockerone.com/uploads/article/20151103/a206a291a8d4b9c968061b853f92ad4e.png">
<meta property="og:image" content="http://dockerone.com/uploads/article/20151031/d569d50a2c6cb4cdb07eb4cfc0712ab0.jpg">
<meta property="og:image" content="http://dockerone.com/uploads/article/20151103/17f6091cc228e14eb151cc8909b4ab00.png">
<meta property="og:image" content="http://dockerone.com/uploads/article/20151031/91b0fd6b6b3c0d372eafbe40221835a8.jpg">
<meta property="og:image" content="http://dockerone.com/uploads/article/20151031/eb03a3d750a4da43fc5825d8336314c1.jpg">
<meta property="og:image" content="http://dockerone.com/uploads/article/20151031/db73c5aad485bbacb3e97d0a8ddcdea4.jpg">
<meta property="og:image" content="http://dockerone.com/uploads/article/20151031/a766de204b53f10d5f56c36955b6b0ee.jpg">
<meta property="og:image" content="http://dockerone.com/uploads/article/20151031/f20de692d890a55b84ee5540c62e054e.jpg">
<meta property="og:updated_time" content="2018-06-29T13:58:50.295Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="学习Docker之10张图带你深入理解Docker容器和镜像">
<meta name="twitter:description" content="刚开始接触Docker之后，就对容器和镜像的概念有所迷惑，上一篇也简单的说了一下之前的见解，其实并不准确，在之后的学习中再加上网上找的资料，发现了下面的这一片博文，一定要多看几遍，看完思考再看，就会对容器和镜像有更深刻的认识。">
<meta name="twitter:image" content="http://dockerone.com/uploads/article/20151103/d6ad9c257d160164480b25b278f4a2ad.png">






  <link rel="canonical" href="http://blog.wangxc.club/2018/01/27/学习Docker之10张图带你深入理解Docker容器和镜像/">



<script type="text/javascript" id="page.configurations">
  CONFIG.page = {
    sidebar: "",
  };
</script>

  <title>学习Docker之10张图带你深入理解Docker容器和镜像 | 冬与晨</title>
  




<script async src="https://www.googletagmanager.com/gtag/js?id=UA-102769182-1"></script>
<script>
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  gtag('js', new Date());

  gtag('config', 'UA-102769182-1');
</script>



  <script type="text/javascript">
    var _hmt = _hmt || [];
    (function() {
      var hm = document.createElement("script");
      hm.src = "https://hm.baidu.com/hm.js?809d5610fca8eaff344d9a698536110d";
      var s = document.getElementsByTagName("script")[0];
      s.parentNode.insertBefore(hm, s);
    })();
  </script>




  <noscript>
  <style type="text/css">
    .use-motion .motion-element,
    .use-motion .brand,
    .use-motion .menu-item,
    .sidebar-inner,
    .use-motion .post-block,
    .use-motion .pagination,
    .use-motion .comments,
    .use-motion .post-header,
    .use-motion .post-body,
    .use-motion .collection-title { opacity: initial; }

    .use-motion .logo,
    .use-motion .site-title,
    .use-motion .site-subtitle {
      opacity: initial;
      top: initial;
    }

    .use-motion {
      .logo-line-before i { left: initial; }
      .logo-line-after i { right: initial; }
    }
  </style>
</noscript>

</head>

<body itemscope itemtype="http://schema.org/WebPage" lang="zh-CN">

  
  
    
  

  <div class="container sidebar-position-left page-post-detail">
    <div class="headband">
    </div>
<a href="https://github.com/vector4wang"><img style="position: absolute; top: 0; right: 0; border: 0;" src="https://s3.amazonaws.com/github/ribbons/forkme_right_darkblue_121621.png" alt="Fork me on GitHub"></a>
    <header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-wrapper">
  <div class="site-meta ">
    

    <div class="custom-logo-site-title">
      <a href="/" class="brand" rel="start">
        <span class="logo-line-before"><i></i></span>
        <span class="site-title">冬与晨</span>
        <span class="logo-line-after"><i></i></span>
      </a>
    </div>
    
  </div>

  <div class="site-nav-toggle">
    <button aria-label="切换导航栏">
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
    </button>
  </div>
</div>



<nav class="site-nav">
  
    <ul id="menu" class="menu">
      
        
        
        
          
          <li class="menu-item menu-item-home">
    <a href="/" rel="section">
      <i class="menu-item-icon fa fa-fw fa-home"></i> <br>首页</a>
  </li>
        
        
        
          
          <li class="menu-item menu-item-about">
    <a href="/about/" rel="section">
      <i class="menu-item-icon fa fa-fw fa-user"></i> <br>关于</a>
  </li>
        
        
        
          
          <li class="menu-item menu-item-tags">
    <a href="/tags/" rel="section">
      <i class="menu-item-icon fa fa-fw fa-tags"></i> <br>标签</a>
  </li>
        
        
        
          
          <li class="menu-item menu-item-categories">
    <a href="/categories/" rel="section">
      <i class="menu-item-icon fa fa-fw fa-th"></i> <br>分类</a>
  </li>
        
        
        
          
          <li class="menu-item menu-item-archives">
    <a href="/archives/" rel="section">
      <i class="menu-item-icon fa fa-fw fa-archive"></i> <br>归档</a>
  </li>
        
        
        
          
          <li class="menu-item menu-item-commonweal">
    <a href="/404/" rel="section">
      <i class="menu-item-icon fa fa-fw fa-heartbeat"></i> <br>公益 404</a>
  </li>

      
      
    </ul>
  

  
    

  

  
</nav>



  



</div>
    </header>

    


    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          
          <div id="content" class="content">
            

  <div id="posts" class="posts-expand">
    

  

  
  
  

  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://blog.wangxc.club/2018/01/27/学习Docker之10张图带你深入理解Docker容器和镜像/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="wangxc">
      <meta itemprop="description" content="革命尚未成功，同志还需努力~">
      <meta itemprop="image" content="/images/avatar.jpg">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="冬与晨">
    </span>

    
      <header class="post-header">

        
        
          <h2 class="post-title" itemprop="name headline">学习Docker之10张图带你深入理解Docker容器和镜像
              
            
          </h2>
        

        <div class="post-meta">
          <span class="post-time">

            
            
            

            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              

              
                
              

              <time title="创建时间：2018-01-27 22:30:53" itemprop="dateCreated datePublished" datetime="2018-01-27T22:30:53+08:00">2018-01-27</time>
            

            
              

              
                
                <span class="post-meta-divider">|</span>
                

                <span class="post-meta-item-icon">
                  <i class="fa fa-calendar-check-o"></i>
                </span>
                
                  <span class="post-meta-item-text">更新于</span>
                
                <time title="修改时间：2018-06-29 21:58:50" itemprop="dateModified" datetime="2018-06-29T21:58:50+08:00">2018-06-29</time>
              
            
          </span>

          
            <span class="post-category">
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing"><a href="/categories/技术/" itemprop="url" rel="index"><span itemprop="name">技术</span></a></span>

                
                
              
            </span>
          

          
            
              <span class="post-comments-count">
                <span class="post-meta-divider">|</span>
                <span class="post-meta-item-icon">
                  <i class="fa fa-comment-o"></i>
                </span>
                <a href="/2018/01/27/学习Docker之10张图带你深入理解Docker容器和镜像/#comments" itemprop="discussionUrl">
                  <span class="post-meta-item-text">评论数：</span> <span class="post-comments-count valine-comment-count" data-xid="/2018/01/27/学习Docker之10张图带你深入理解Docker容器和镜像/" itemprop="commentCount"></span>
                </a>
              </span>
            
          

          
          

          

          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        <p>刚开始接触Docker之后，就对容器和镜像的概念有所迷惑，上一篇也简单的说了一下之前的见解，其实并不准确，在之后的学习中再加上网上找的资料，发现了下面的这一片博文，一定要多看几遍，看完思考再看，就会对容器和镜像有更深刻的认识。</p>
<a id="more"></a>

<iframe frameborder="no" border="0" marginwidth="0" marginheight="0" width="330" height="86" src="//music.163.com/outchain/player?type=2&id=427142136&auto=1&height=66"></iframe>

<p>原文链接：<a href="http://dockone.io/article/783" target="_blank" rel="noopener">http://dockone.io/article/783</a></p>
<blockquote>
<p>【编者的话】本文用图文并茂的方式介绍了容器、镜像的区别和Docker每个命令后面的技术细节，能够很好的帮助读者深入理解Docker。</p>
</blockquote>
<p>这篇文章希望能够帮助读者深入理解Docker的命令，还有容器（container）和镜像（image）之间的区别，并深入探讨容器和运行中的容器之间的区别。<br><img src="http://dockerone.com/uploads/article/20151103/d6ad9c257d160164480b25b278f4a2ad.png" alt="pasted_image_0.png"> </p>
<p>当我对Docker技术还是一知半解的时候，我发现理解Docker的命令非常困难。于是，我花了几周的时间来学习Docker的工作原理，更确切地说，是关于Docker统一文件系统（the union file system）的知识，然后回过头来再看Docker的命令，一切变得顺理成章，简单极了。</p>
<p><strong>题外话</strong>：就我个人而言，掌握一门技术并合理使用它的最好办法就是深入理解这项技术背后的工作原理。通常情况下，一项新技术的诞生常常会伴随着媒体的大肆宣传和炒作，这使得用户很难看清技术的本质。更确切地说，新技术总是会发明一些新的术语或者隐喻词来帮助宣传，这在初期是非常有帮助的，但是这给技术的原理蒙上了一层砂纸，不利于用户在后期掌握技术的真谛。</p>
<p>Git就是一个很好的例子。我之前不能够很好的使用Git，于是我花了一段时间去学习Git的原理，直到这时，我才真正明白了Git的用法。我坚信只有真正理解Git内部原理的人才能够掌握这个工具。</p>
<h3 id="Image-Definition"><a href="#Image-Definition" class="headerlink" title="Image Definition"></a>Image Definition</h3><p>镜像（Image）就是一堆只读层（read-only layer）的统一视角，也许这个定义有些难以理解，下面的这张图能够帮助读者理解镜像的定义。<br><img src="http://dockerone.com/uploads/article/20151103/522c40256149bad2b471d1a97c2b6bb5.png" alt="1.png"><br>从左边我们看到了多个只读层，它们重叠在一起。除了最下面一层，其它层都会有一个指针指向下一层。这些层是Docker内部的实现细节，并且能够在主机（译者注：运行Docker的机器）的文件系统上访问到。统一文件系统（union file system）技术能够将不同的层整合成一个文件系统，为这些层提供了一个统一的视角，这样就隐藏了多层的存在，在用户的角度看来，只存在一个文件系统。我们可以在图片的右边看到这个视角的形式。</p>
<p>你可以在你的主机文件系统上找到有关这些层的文件。需要注意的是，在一个运行中的容器内部，这些层是不可见的。在我的主机上，我发现它们存在于/var/lib/docker/aufs目录下。</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br></pre></td><td class="code"><pre><span class="line">sudo tree -L 1 /var/lib/docker/</span><br><span class="line">/var/lib/docker/</span><br><span class="line"></span><br><span class="line">├─aufs</span><br><span class="line">├─containers</span><br><span class="line">├─graph</span><br><span class="line">├─init</span><br><span class="line">├─linkgraph.db</span><br><span class="line">├─repositories-aufs</span><br><span class="line">├─tmp</span><br><span class="line">├─trust</span><br><span class="line">└─volumes</span><br></pre></td></tr></table></figure>

<h3 id="Container-Definition"><a href="#Container-Definition" class="headerlink" title="Container Definition"></a>Container Definition</h3><p>容器（container）的定义和镜像（image）几乎一模一样，也是一堆层的统一视角，唯一区别在于容器的最上面那一层是可读可写的。<br><img src="http://dockerone.com/uploads/article/20151103/b7fb9d924aa12099369c4793050fcfab.png" alt="2.png"></p>
<p>细心的读者可能会发现，容器的定义并没有提及容器是否在运行，没错，这是故意的。正是这个发现帮助我理解了很多困惑。</p>
<p>要点：容器 = 镜像 + 读写层。并且容器的定义并没有提及是否要运行容器。</p>
<p>接下来，我们将会讨论运行态容器。</p>
<h3 id="Running-Container-Definition"><a href="#Running-Container-Definition" class="headerlink" title="Running Container Definition"></a>Running Container Definition</h3><p>一个运行态容器（running container）被定义为一个可读写的统一文件系统加上隔离的进程空间和包含其中的进程。下面这张图片展示了一个运行中的容器。<br><img src="http://dockerone.com/uploads/article/20151103/8022edeebeb313742bd615aa695bbad3.png" alt="3.png"></p>
<p>正是文件系统隔离技术使得Docker成为了一个前途无量的技术。一个容器中的进程可能会对文件进行修改、删除、创建，这些改变都将作用于可读写层（read-write layer）。下面这张图展示了这个行为。<br><img src="http://dockerone.com/uploads/article/20151103/1dc88de5a114b68d05c37aab7e103597.png" alt="4.png"><br>我们可以通过运行以下命令来验证我们上面所说的：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">docker run ubuntu touch happiness.txt</span><br></pre></td></tr></table></figure>

<p>即便是这个ubuntu容器不再运行，我们依旧能够在主机的文件系统上找到这个新文件。</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">find / -name happiness.txt</span><br><span class="line">/var/lib/docker/aufs/diff/860a7b...889/happiness.txt</span><br></pre></td></tr></table></figure>

<h3 id="Image-Layer-Definition"><a href="#Image-Layer-Definition" class="headerlink" title="Image Layer Definition"></a>Image Layer Definition</h3><p>为了将零星的数据整合起来，我们提出了镜像层（image layer）这个概念。下面的这张图描述了一个镜像层，通过图片我们能够发现一个层并不仅仅包含文件系统的改变，它还能包含了其他重要信息。<br><img src="http://dockerone.com/uploads/article/20151103/e42d56394306894244af5bc6d757bee1.png" alt="5.png"><br>元数据（metadata）就是关于这个层的额外信息，它不仅能够让Docker获取运行和构建时的信息，还包括父层的层次信息。需要注意，只读层和读写层都包含元数据。<br><img src="http://dockerone.com/uploads/article/20151103/5cca590212e2a110be84cbdd3b6101ee.png" alt="6.png"><br>除此之外，每一层都包括了一个指向父层的指针。如果一个层没有这个指针，说明它处于最底层。<br><img src="http://dockerone.com/uploads/article/20151103/1ead4d955aeb5d968219794489948fc2.png" alt="8.png"><br><strong>Metadata Location:</strong><br>我发现在我自己的主机上，镜像层（image layer）的元数据被保存在名为”json”的文件中，比如说：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">/var/lib/docker/graph/e809f156dc985.../json</span><br></pre></td></tr></table></figure>

<p>e809f156dc985…就是这层的id</p>
<p>一个容器的元数据好像是被分成了很多文件，但或多或少能够在/var/lib/docker/containers/<id>目录下找到<id>就是一个可读层的id。这个目录下的文件大多是运行时的数据，比如说网络，日志等等。</id></id></p>
<h3 id="全局理解（Tying-It-All-Together）"><a href="#全局理解（Tying-It-All-Together）" class="headerlink" title="全局理解（Tying It All Together）"></a>全局理解（Tying It All Together）</h3><p>现在，让我们结合上面提到的实现细节来理解Docker的命令。</p>
<h4 id="docker-create"><a href="#docker-create" class="headerlink" title="docker create "></a>docker create <image-id></image-id></h4><p><img src="http://dockerone.com/uploads/article/20151031/1397bbddca6651a3ae0316daa8d6d1cd.jpg" alt="create.jpg"></p>
<p>docker create 命令为指定的镜像（image）添加了一个可读写层，构成了一个新的容器。注意，这个容器并没有运行。<br><img src="http://dockerone.com/uploads/article/20151103/bbe622329b399778b077617ae6468676.png" alt="11.png"></p>
<h4 id="docker-start"><a href="#docker-start" class="headerlink" title="docker start "></a>docker start <container-id></container-id></h4><p><img src="http://dockerone.com/uploads/article/20151031/3f08537e309b923d049fdde3d3a1f926.jpg" alt="start.jpg"></p>
<p>Docker start命令为容器文件系统创建了一个进程隔离空间。注意，每一个容器只能够有一个进程隔离空间。</p>
<h4 id="docker-run-lt-image-id-gt"><a href="#docker-run-lt-image-id-gt" class="headerlink" title="docker run &lt;image-id&gt;"></a>docker run &lt;image-id&gt;</h4><p><img src="http://dockerone.com/uploads/article/20151031/4178f2b64f6a2eeb994866931417f263.jpg" alt="run.jpg"><br>看到这个命令，读者通常会有一个疑问：docker start 和 docker run命令有什么区别。<br><img src="http://dockerone.com/uploads/article/20151103/ea18907dedcd8893b39ae1f9e3ad8a3e.png" alt="7.png"></p>
<p>从图片可以看出，docker run 命令先是利用镜像创建了一个容器，然后运行这个容器。这个命令非常的方便，并且隐藏了两个命令的细节，但从另一方面来看，这容易让用户产生误解。</p>
<p>题外话：继续我们之前有关于Git的话题，我认为docker run命令类似于git pull命令。git pull命令就是git fetch 和 git merge两个命令的组合，同样的，docker run就是docker create和docker start两个命令的组合。</p>
<h4 id="docker-ps"><a href="#docker-ps" class="headerlink" title="docker ps"></a>docker ps</h4><p><img src="http://dockerone.com/uploads/article/20151031/fafeb4eb072e64b54b9979930a6d8db7.jpg" alt="ps.jpg"></p>
<p>docker ps 命令会列出所有运行中的容器。这隐藏了非运行态容器的存在，如果想要找出这些容器，我们需要使用下面这个命令。</p>
<h4 id="docker-ps-–a"><a href="#docker-ps-–a" class="headerlink" title="docker ps –a"></a>docker ps –a</h4><p><img src="http://dockerone.com/uploads/article/20151031/120d394e57a03a5bb996b23e6e373cf1.jpg" alt="ps0a.jpg"></p>
<p>docker ps –a命令会列出所有的容器，不管是运行的，还是停止的。</p>
<h4 id="docker-images"><a href="#docker-images" class="headerlink" title="docker images"></a>docker images</h4><p><a href="http://dockerone.com/uploads/article/20151031/f8b34de7f7f325e2933aac5cc679e224.jpg" target="_blank" rel="noopener"><img src="http://dockerone.com/uploads/article/20151031/f8b34de7f7f325e2933aac5cc679e224.jpg" alt="images.jpg" title="images.jpg"></a></p>
<p>docker images命令会列出了所有顶层（top-level）镜像。实际上，在这里我们没有办法区分一个镜像和一个只读层，所以我们提出了top-level镜像。只有创建容器时使用的镜像或者是直接pull下来的镜像能被称为顶层（top-level）镜像，并且每一个顶层镜像下面都隐藏了多个镜像层。</p>
<h4 id="docker-images-–a"><a href="#docker-images-–a" class="headerlink" title="docker images –a"></a>docker images –a</h4><p><a href="http://dockerone.com/uploads/article/20151031/6b3d2d1cae5a26961dc554fc05783b22.jpg" target="_blank" rel="noopener"><img src="http://dockerone.com/uploads/article/20151031/6b3d2d1cae5a26961dc554fc05783b22.jpg" alt="images-a.jpg" title="images-a.jpg"></a></p>
<p>docker images –a命令列出了所有的镜像，也可以说是列出了所有的可读层。如果你想要查看某一个image-id下的所有层，可以使用docker history来查看。</p>
<h4 id="docker-stop-lt-container-id-gt"><a href="#docker-stop-lt-container-id-gt" class="headerlink" title="docker stop &lt;container-id&gt;"></a>docker stop &lt;container-id&gt;</h4><p><a href="http://dockerone.com/uploads/article/20151031/081cf8fbe8ab4dea4130ce2f25eae071.jpg" target="_blank" rel="noopener"><img src="http://dockerone.com/uploads/article/20151031/081cf8fbe8ab4dea4130ce2f25eae071.jpg" alt="stop.jpg" title="stop.jpg"></a></p>
<p>docker stop命令会向运行中的容器发送一个SIGTERM的信号，然后停止所有的进程。</p>
<h4 id="docker-kill-lt-container-id-gt"><a href="#docker-kill-lt-container-id-gt" class="headerlink" title="docker kill &lt;container-id&gt;"></a>docker kill &lt;container-id&gt;</h4><p><a href="http://dockerone.com/uploads/article/20151031/8aeee0c4c1134ee9d0c2200e03defcf4.jpg" target="_blank" rel="noopener"><img src="http://dockerone.com/uploads/article/20151031/8aeee0c4c1134ee9d0c2200e03defcf4.jpg" alt="kill.jpg" title="kill.jpg"></a></p>
<p>docker kill 命令向所有运行在容器中的进程发送了一个不友好的SIGKILL信号。</p>
<h4 id="docker-pause-lt-container-id-gt"><a href="#docker-pause-lt-container-id-gt" class="headerlink" title="docker pause &lt;container-id&gt;"></a>docker pause &lt;container-id&gt;</h4><p><a href="http://dockerone.com/uploads/article/20151031/2b34576a2187a972d4cc1cf9346658e2.jpg" target="_blank" rel="noopener"><img src="http://dockerone.com/uploads/article/20151031/2b34576a2187a972d4cc1cf9346658e2.jpg" alt="pause.jpg" title="pause.jpg"></a></p>
<p>docker stop和docker kill命令会发送UNIX的信号给运行中的进程，docker pause命令则不一样，它利用了cgroups的特性将运行中的进程空间暂停。具体的内部原理你可以在这里找到：<a href="https://www.kernel.org/doc/Documentation/cgroups/freezer-subsystem.txt" target="_blank" rel="noopener"></a><a href="https://www.kernel.org/doc/Documentation/cgroups/freezer-subsystem.txt" target="_blank" rel="noopener">https://www.kernel.org/doc/Doc … m.txt</a>，但是这种方式的不足之处在于发送一个SIGTSTP信号对于进程来说不够简单易懂，以至于不能够让所有进程暂停。</p>
<h4 id="docker-rm-lt-container-id-gt"><a href="#docker-rm-lt-container-id-gt" class="headerlink" title="docker rm &lt;container-id&gt;"></a>docker rm &lt;container-id&gt;</h4><p><a href="http://dockerone.com/uploads/article/20151031/bba4521356b43813a634a0859fa53743.jpg" target="_blank" rel="noopener"><img src="http://dockerone.com/uploads/article/20151031/bba4521356b43813a634a0859fa53743.jpg" alt="rm.jpg" title="rm.jpg"></a><br>docker rm命令会移除构成容器的可读写层。注意，这个命令只能对非运行态容器执行。</p>
<h4 id="docker-rmi-lt-image-id-gt"><a href="#docker-rmi-lt-image-id-gt" class="headerlink" title="docker rmi &lt;image-id&gt;"></a>docker rmi &lt;image-id&gt;</h4><p><a href="http://dockerone.com/uploads/article/20151031/df0fadb17158696cdce49a8e30f8c4c4.jpg" target="_blank" rel="noopener"><img src="http://dockerone.com/uploads/article/20151031/df0fadb17158696cdce49a8e30f8c4c4.jpg" alt="rmi.jpg" title="rmi.jpg"></a></p>
<p>docker rmi 命令会移除构成镜像的一个只读层。你只能够使用docker rmi来移除最顶层（top level layer）（也可以说是镜像），你也可以使用-f参数来强制删除中间的只读层。 </p>
<h4 id="docker-commit"><a href="#docker-commit" class="headerlink" title="docker commit "></a>docker commit <container-id></container-id></h4><p><a href="http://dockerone.com/uploads/article/20151031/f642149d0144c83679dd228c93a91a37.jpg" target="_blank" rel="noopener"><img src="http://dockerone.com/uploads/article/20151031/f642149d0144c83679dd228c93a91a37.jpg" alt="commit.jpg" title="commit.jpg"></a></p>
<p>docker commit命令将容器的可读写层转换为一个只读层，这样就把一个容器转换成了不可变的镜像。</p>
<p><a href="http://dockerone.com/uploads/article/20151103/a206a291a8d4b9c968061b853f92ad4e.png" target="_blank" rel="noopener"><img src="http://dockerone.com/uploads/article/20151103/a206a291a8d4b9c968061b853f92ad4e.png" alt="10.png" title="10.png"></a></p>
<h4 id="docker-build"><a href="#docker-build" class="headerlink" title="docker build"></a>docker build</h4><p><a href="http://dockerone.com/uploads/article/20151031/d569d50a2c6cb4cdb07eb4cfc0712ab0.jpg" target="_blank" rel="noopener"><img src="http://dockerone.com/uploads/article/20151031/d569d50a2c6cb4cdb07eb4cfc0712ab0.jpg" alt="build.jpg" title="build.jpg"></a></p>
<p>docker build命令非常有趣，它会反复的执行多个命令。</p>
<p><a href="http://dockerone.com/uploads/article/20151103/17f6091cc228e14eb151cc8909b4ab00.png" target="_blank" rel="noopener"><img src="http://dockerone.com/uploads/article/20151103/17f6091cc228e14eb151cc8909b4ab00.png" alt="9.png" title="9.png"></a></p>
<p>我们从上图可以看到，build命令根据Dockerfile文件中的FROM指令获取到镜像，然后重复地1）run（create和start）、2）修改、3）commit。在循环中的每一步都会生成一个新的层，因此许多新的层会被创建。</p>
<h4 id="docker-exec-lt-running-container-id-gt"><a href="#docker-exec-lt-running-container-id-gt" class="headerlink" title="docker exec &lt;running-container-id&gt;"></a>docker exec &lt;running-container-id&gt;</h4><p><a href="http://dockerone.com/uploads/article/20151031/91b0fd6b6b3c0d372eafbe40221835a8.jpg" target="_blank" rel="noopener"><img src="http://dockerone.com/uploads/article/20151031/91b0fd6b6b3c0d372eafbe40221835a8.jpg" alt="exec.jpg" title="exec.jpg"></a><br>docker exec 命令会在运行中的容器执行一个新进程。</p>
<h4 id="docker-inspect-lt-container-id-gt-or-lt-image-id-gt"><a href="#docker-inspect-lt-container-id-gt-or-lt-image-id-gt" class="headerlink" title="docker inspect &lt;container-id&gt; or &lt;image-id&gt;"></a>docker inspect &lt;container-id&gt; or &lt;image-id&gt;</h4><p><a href="http://dockerone.com/uploads/article/20151031/eb03a3d750a4da43fc5825d8336314c1.jpg" target="_blank" rel="noopener"><img src="http://dockerone.com/uploads/article/20151031/eb03a3d750a4da43fc5825d8336314c1.jpg" alt="insepect.jpg" title="insepect.jpg"></a></p>
<p>docker inspect命令会提取出容器或者镜像最顶层的元数据。</p>
<h4 id="docker-save-lt-image-id-gt"><a href="#docker-save-lt-image-id-gt" class="headerlink" title="docker save &lt;image-id&gt;"></a>docker save &lt;image-id&gt;</h4><p><a href="http://dockerone.com/uploads/article/20151031/db73c5aad485bbacb3e97d0a8ddcdea4.jpg" target="_blank" rel="noopener"><img src="http://dockerone.com/uploads/article/20151031/db73c5aad485bbacb3e97d0a8ddcdea4.jpg" alt="save.jpg" title="save.jpg"></a></p>
<p>docker save命令会创建一个镜像的压缩文件，这个文件能够在另外一个主机的Docker上使用。和export命令不同，这个命令为每一个层都保存了它们的元数据。这个命令只能对镜像生效。</p>
<h4 id="docker-export-lt-container-id-gt"><a href="#docker-export-lt-container-id-gt" class="headerlink" title="docker export &lt;container-id&gt;"></a>docker export &lt;container-id&gt;</h4><p><a href="http://dockerone.com/uploads/article/20151031/a766de204b53f10d5f56c36955b6b0ee.jpg" target="_blank" rel="noopener"><img src="http://dockerone.com/uploads/article/20151031/a766de204b53f10d5f56c36955b6b0ee.jpg" alt="export.jpg" title="export.jpg"></a></p>
<p>docker export命令创建一个tar文件，并且移除了元数据和不必要的层，将多个层整合成了一个层，只保存了当前统一视角看到的内容（译者注：expoxt后的容器再import到Docker中，通过docker images –tree命令只能看到一个镜像；而save后的镜像则不同，它能够看到这个镜像的历史镜像）。</p>
<h4 id="docker-history-lt-image-id-gt"><a href="#docker-history-lt-image-id-gt" class="headerlink" title="docker history &lt;image-id&gt;"></a>docker history &lt;image-id&gt;</h4><p><a href="http://dockerone.com/uploads/article/20151031/f20de692d890a55b84ee5540c62e054e.jpg" target="_blank" rel="noopener"><img src="http://dockerone.com/uploads/article/20151031/f20de692d890a55b84ee5540c62e054e.jpg" alt="history.jpg" title="history.jpg"></a></p>
<p>docker history命令递归地输出指定镜像的历史镜像。</p>
<h3 id="结论"><a href="#结论" class="headerlink" title="结论"></a>结论</h3><p>我希望你们能喜欢这篇文章。还有其他许多的命令（pull，search，restart，attach等）我没有提及，但是我相信通过阅读这篇文章，大部分的Docker命令都能够被很好理解。我仅仅学习了Docker两个星期，因此，如果我有什么地方说的不好，欢迎大家指出。</p>
<p><strong>原文链接：<a href="http://merrigrove.blogspot.sg/2015/10/visualizing-docker-containers-and-images.html" target="_blank" rel="noopener">Visualizing Docker Containers and Images</a>（翻译：杨润青）</strong></p>
<p>＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝</p>
<p><strong>译者介绍</strong></p>
<p>杨润青，90后博士僧，研究方向是网络和信息安全。</p>
<p>CSDN：<a href="http://blog.csdn.net/qqhjqs?viewmode=list" target="_blank" rel="noopener">http://blog.csdn.net/qqhjqs?viewmode=list</a><br>博客：<a href="http://vector4wang.tk/" target="_blank" rel="noopener">http://vector4wang.tk/</a><br>简书：<a href="https://www.jianshu.com/u/223a1314e818" target="_blank" rel="noopener">https://www.jianshu.com/u/223a1314e818</a><br>Github:<a href="https://github.com/vector4wang" target="_blank" rel="noopener">https://github.com/vector4wang</a><br>Gitee:<a href="https://gitee.com/backwxc" target="_blank" rel="noopener">https://gitee.com/backwxc</a><br>如果感觉有帮助的话，点个赞哦~</p>

      
    </div>

    

    
    
    

    <div>
          
            
          
    </div>

    

    
      <div>
        <div style="padding: 10px 0; margin: 20px auto; width: 90%; text-align: center;">
  <div></div>
  <button id="rewardButton" disable="enable" onclick="var qr = document.getElementById('QR'); if (qr.style.display === 'none') {qr.style.display='block';} else {qr.style.display='none'}">
    <span>打赏</span>
  </button>
  <div id="QR" style="display: none;">

    
      <div id="wechat" style="display: inline-block">
        <img id="wechat_qr" src="https://i.loli.net/2017/12/29/5a4632028eaeb.jpg" alt="wangxc 微信支付">
        <p>微信支付</p>
      </div>
    

    
      <div id="alipay" style="display: inline-block">
        <img id="alipay_qr" src="https://i.loli.net/2017/12/29/5a46320234b1d.jpg" alt="wangxc 支付宝">
        <p>支付宝</p>
      </div>
    

    

  </div>
</div>

      </div>
    

    
<div>
  
    <div>
    
        <div style="text-align:center;color: #ccc;font-size:14px;">
              -------------本文结束<i class="fa fa-paw"></i>感谢您的阅读-------------
        </div>
    
</div>

  
</div>
    <footer class="post-footer">
      
        <div class="post-tags">
          
            <a href="/tags/Docker/" rel="tag"><i class="fa fa-tag"></i> Docker</a>
          
        </div>
      

      
      
      

      
        <div class="post-nav">
          <div class="post-nav-next post-nav-item">
            
              <a href="/2018/01/22/学习Docker之Docker、容器和镜像的简介和常用命令/" rel="next" title="学习Docker之Docker、容器和镜像的简介和常用命令">
                <i class="fa fa-chevron-left"></i> 学习Docker之Docker、容器和镜像的简介和常用命令
              </a>
            
          </div>

          <span class="post-nav-divider"></span>

          <div class="post-nav-prev post-nav-item">
            
              <a href="/2018/02/01/学习Docker之Dockerfile的命令/" rel="prev" title="学习Docker之Dockerfile的命令">
                学习Docker之Dockerfile的命令 <i class="fa fa-chevron-right"></i>
              </a>
            
          </div>
        </div>
      

      
      
    </footer>
  </div>
  
  
  
  </article>



    <div class="post-spread">
      
    </div>
  </div>


          </div>
          

  
    <div class="comments" id="comments">
    </div>
  



        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    
    <div class="sidebar-inner">

      

      
        <ul class="sidebar-nav motion-element">
          <li class="sidebar-nav-toc sidebar-nav-active" data-target="post-toc-wrap">
            文章目录
          </li>
          <li class="sidebar-nav-overview" data-target="site-overview-wrap">
            站点概览
          </li>
        </ul>
      

      <section class="site-overview-wrap sidebar-panel">
        <div class="site-overview">
          <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
            
              <img class="site-author-image" itemprop="image" src="/images/avatar.jpg" alt="wangxc">
            
              <p class="site-author-name" itemprop="name">wangxc</p>
              <p class="site-description motion-element" itemprop="description">革命尚未成功，同志还需努力~</p>
          </div>

          
            <nav class="site-state motion-element">
              
                <div class="site-state-item site-state-posts">
                
                  <a href="/archives/">
                
                    <span class="site-state-item-count">83</span>
                    <span class="site-state-item-name">日志</span>
                  </a>
                </div>
              

              
                
                
                <div class="site-state-item site-state-categories">
                  <a href="/categories/index.html">
                    
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                    <span class="site-state-item-count">6</span>
                    <span class="site-state-item-name">分类</span>
                  </a>
                </div>
              

              
                
                
                <div class="site-state-item site-state-tags">
                  <a href="/tags/index.html">
                    
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                    <span class="site-state-item-count">124</span>
                    <span class="site-state-item-name">标签</span>
                  </a>
                </div>
              
            </nav>
          

          

          
            <div class="links-of-author motion-element">
              
                <span class="links-of-author-item">
                  <a href="https://github.com/vector4wang" target="_blank" title="GitHub" rel="external nofollow"><i class="fa fa-fw fa-github"></i>GitHub</a>
                  
                </span>
              
                <span class="links-of-author-item">
                  <a href="mailto:vector4wang@qq.com" target="_blank" title="E-Mail" rel="external nofollow"><i class="fa fa-fw fa-envelope"></i>E-Mail</a>
                  
                </span>
              
                <span class="links-of-author-item">
                  <a href="https://www.jianshu.com/u/223a1314e818" target="_blank" title="简书" rel="external nofollow"><i class="fa fa-fw fa-book"></i>简书</a>
                  
                </span>
              
                <span class="links-of-author-item">
                  <a href="http://blog.csdn.net/qqhjqs?viewmode=contents" target="_blank" title="CSDN" rel="external nofollow"><i class="fa fa-fw fa-crosshairs"></i>CSDN</a>
                  
                </span>
              
                <span class="links-of-author-item">
                  <a href="https://twitter.com/BMHJQS" target="_blank" title="Twitter" rel="external nofollow"><i class="fa fa-fw fa-twitter"></i>Twitter</a>
                  
                </span>
              
                <span class="links-of-author-item">
                  <a href="https://www.facebook.com/" target="_blank" title="FB Page" rel="external nofollow"><i class="fa fa-fw fa-facebook-official"></i>FB Page</a>
                  
                </span>
              
            </div>
          

          
          

          
          

          
            
          
          

        </div>
      </section>

      
      <!--noindex-->
        <section class="post-toc-wrap motion-element sidebar-panel sidebar-panel-active">
          <div class="post-toc">

            
              
            

            
              <div class="post-toc-content"><ol class="nav"><li class="nav-item nav-level-3"><a class="nav-link" href="#Image-Definition"><span class="nav-number">1.</span> <span class="nav-text">Image Definition</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#Container-Definition"><span class="nav-number">2.</span> <span class="nav-text">Container Definition</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#Running-Container-Definition"><span class="nav-number">3.</span> <span class="nav-text">Running Container Definition</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#Image-Layer-Definition"><span class="nav-number">4.</span> <span class="nav-text">Image Layer Definition</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#全局理解（Tying-It-All-Together）"><span class="nav-number">5.</span> <span class="nav-text">全局理解（Tying It All Together）</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#docker-create"><span class="nav-number">5.1.</span> <span class="nav-text">docker create </span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#docker-start"><span class="nav-number">5.2.</span> <span class="nav-text">docker start </span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#docker-run-lt-image-id-gt"><span class="nav-number">5.3.</span> <span class="nav-text">docker run &lt;image-id&gt;</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#docker-ps"><span class="nav-number">5.4.</span> <span class="nav-text">docker ps</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#docker-ps-–a"><span class="nav-number">5.5.</span> <span class="nav-text">docker ps –a</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#docker-images"><span class="nav-number">5.6.</span> <span class="nav-text">docker images</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#docker-images-–a"><span class="nav-number">5.7.</span> <span class="nav-text">docker images –a</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#docker-stop-lt-container-id-gt"><span class="nav-number">5.8.</span> <span class="nav-text">docker stop &lt;container-id&gt;</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#docker-kill-lt-container-id-gt"><span class="nav-number">5.9.</span> <span class="nav-text">docker kill &lt;container-id&gt;</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#docker-pause-lt-container-id-gt"><span class="nav-number">5.10.</span> <span class="nav-text">docker pause &lt;container-id&gt;</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#docker-rm-lt-container-id-gt"><span class="nav-number">5.11.</span> <span class="nav-text">docker rm &lt;container-id&gt;</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#docker-rmi-lt-image-id-gt"><span class="nav-number">5.12.</span> <span class="nav-text">docker rmi &lt;image-id&gt;</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#docker-commit"><span class="nav-number">5.13.</span> <span class="nav-text">docker commit </span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#docker-build"><span class="nav-number">5.14.</span> <span class="nav-text">docker build</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#docker-exec-lt-running-container-id-gt"><span class="nav-number">5.15.</span> <span class="nav-text">docker exec &lt;running-container-id&gt;</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#docker-inspect-lt-container-id-gt-or-lt-image-id-gt"><span class="nav-number">5.16.</span> <span class="nav-text">docker inspect &lt;container-id&gt; or &lt;image-id&gt;</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#docker-save-lt-image-id-gt"><span class="nav-number">5.17.</span> <span class="nav-text">docker save &lt;image-id&gt;</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#docker-export-lt-container-id-gt"><span class="nav-number">5.18.</span> <span class="nav-text">docker export &lt;container-id&gt;</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#docker-history-lt-image-id-gt"><span class="nav-number">5.19.</span> <span class="nav-text">docker history &lt;image-id&gt;</span></a></li></ol></li><li class="nav-item nav-level-3"><a class="nav-link" href="#结论"><span class="nav-number">6.</span> <span class="nav-text">结论</span></a></li></ol></div>
            

          </div>
        </section>
      <!--/noindex-->
      

      
        <div class="back-to-top">
          <i class="fa fa-arrow-up"></i>
          
            <span id="scrollpercent"><span>0</span>%</span>
          
        </div>
      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <script async src="https://dn-lbstatics.qbox.me/busuanzi/2.3/busuanzi.pure.mini.js"></script>
<div class="copyright">&copy; <span itemprop="copyrightYear">2020</span>
  <span class="with-love" id="animate">
    <i class="fa fa-user"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">wangxc</span>

  

  
</div>


  


<div class="powered-by">
<i class="fa fa-user-md"></i><span id="busuanzi_container_site_pv">
  本站访客数:<span id="busuanzi_value_site_uv"></span>
</span>
</div>


  <div class="powered-by">由 <a class="theme-link" target="_blank" rel="external nofollow" href="https://hexo.io">Hexo</a> 强力驱动 v3.8.0</div>



  <span class="post-meta-divider">|</span>



  <div class="theme-info">主题 &mdash; <a class="theme-link" target="_blank" rel="external nofollow" href="https://theme-next.org">NexT.Mist</a> v6.3.0</div>




        








        
      </div>
    </footer>

    

    

  </div>

  

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>


























  
  
    <script type="text/javascript" src="/lib/jquery/index.js?v=2.1.3"></script>
  

  
  
    <script type="text/javascript" src="/lib/velocity/velocity.min.js?v=1.2.1"></script>
  

  
  
    <script type="text/javascript" src="/lib/velocity/velocity.ui.min.js?v=1.2.1"></script>
  


  


  <script type="text/javascript" src="/js/src/utils.js?v=6.3.0"></script>

  <script type="text/javascript" src="/js/src/motion.js?v=6.3.0"></script>



  
  

  
  <script type="text/javascript" src="/js/src/scrollspy.js?v=6.3.0"></script>
<script type="text/javascript" src="/js/src/post-details.js?v=6.3.0"></script>



  


  <script type="text/javascript" src="/js/src/bootstrap.js?v=6.3.0"></script>



  



	





  





  








  <script src="//cdn1.lncld.net/static/js/3.0.4/av-min.js"></script>
  
  
  <script src="//unpkg.com/valine/dist/Valine.min.js"></script>
  
  <script type="text/javascript">
    var GUEST = ['nick','mail','link'];
    var guest = 'nick,mail,link';
    guest = guest.split(',').filter(function (item) {
      return GUEST.indexOf(item)>-1;
    });
    new Valine({
        el: '#comments' ,
        verify: false,
        notify: false,
        appId: 'YdGFHBfuDwObik8qwCeRAWgr-gzGzoHsz',
        appKey: 'oFpbJwmMQf98DfFDUlzE5Fai',
        placeholder: 'Just go go',
        avatar:'mm',
        guest_info:guest,
        pageSize:'10' || 10,
    });
  </script>



  





  

  

  

  

  
  

  

  

  

  

  

</body>
</html>
